package com.project.poetry.service.controller;

import com.project.poetry.service.entity.dto.user.SaveDetailUserDTO;
import com.project.poetry.service.entity.po.user.UserPO;
import com.project.poetry.service.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 人员控制器
 * @author mengxj
 */
@Api("人员")
@RestController
@RequestMapping("user")
public class UserController {

    @Resource
    private UserService userService;

    @ApiOperation("通过人员id获取人员信息")
    @GetMapping("getById/{id}")
    public UserPO getById(@PathVariable("id") Long id){
        return this.userService.getById(id);
    }

    @ApiOperation("保存人员信息")
    @PostMapping("saveDetail")
    public void saveDetail(@RequestBody SaveDetailUserDTO user){
        this.userService.saveDetail(user);
    }

    @ApiOperation("查询所有人")
    @PostMapping("selectAll")
    public List<UserPO> selectAll(){
        return this.userService.list();
    }
}
